define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'company/index',
                    add_url: 'company/add',
                    edit_url: 'company/edit',
                    del_url: 'company/del',
                    multi_url: 'company/multi',
                    table: 'userinfo',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'username', title: __('Username')},
                        {field: 'password', title: __('Password')},
                        {field: 'icp_code', title: __('Icp_code')},
                        {field: 'legalpeople', title: __('Legalpeople')},
                        {field: 'connect_method', title: __('Connect_method')},
                        {field: 'company_name', title: __('Company_name')},
                        {field: 'company_address', title: __('Company_address')},
                        {field: 'connect_tel', title: __('Connect_tel')},
                        {field: 'email', title: __('Email')},
                        {field: 'weixin_img', title: __('Weixin_img')},
                        {field: 'leftad_name', title: __('Leftad_name')},
                        {field: 'leftad_img', title: __('Leftad_img')},
                        {field: 'leftlink', title: __('Leftlink')},
                        {field: 'wangwang', title: __('Wangwang')},
                        {field: 'fax_num', title: __('Fax_num')},
                        {field: 'connect_people', title: __('Connect_people')},
                        {field: 'qq1', title: __('Qq1')},
                        {field: 'qq2', title: __('Qq2')},
                        {field: 'legalurl', title: __('Legalurl'), formatter: Table.api.formatter.url},
                        {field: 'industry_category', title: __('Industry_category')},
                        {field: 'company_logo', title: __('Company_logo')},
                        {field: 'mobile_logo', title: __('Mobile_logo')},
                        {field: 'industry_keywords', title: __('Industry_keywords')},
                        {field: 'company_remark', title: __('Company_remark')},
                        {field: 'construction', title: __('Construction')},
                        {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'culture', title: __('Culture')},
                        {field: 'seo_keywords', title: __('Seo_keywords')},
                        {field: 'uid', title: __('Uid')},
                        {field: 'version', title: __('Version')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});